﻿using Common.Package;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Common.Handle
{
    /// <summary>
    /// 打开注册界面
    /// </summary>
    public class MapleRegisterUIHandle:MaplePacketHandler
    {

        public void HandlePacket(MapleClient clinet, Buffer.MaplePacketRead slea)
        {
            clinet.Send(MapleLoginPacket.ShowRegisterUI(true));
        }
    }

    /// <summary>
    /// 帐号检测处理
    /// </summary>
    public class MapleCheckAccountsHandle : MaplePacketHandler
    {

        public void HandlePacket(MapleClient clinet, Buffer.MaplePacketRead slea)
        {
            string Name = slea.ReadMapleAsciiString();

            clinet.Send(MapleLoginPacket.CheckAccounts(Name, !clinet.isCheckAccount(Name)));
            //throw new NotImplementedException();
        }
    }

    /// <summary>
    /// 帐号注册事件
    /// </summary>
    public class MapleRegisterHandle : MaplePacketHandler
    {

        public void HandlePacket(MapleClient clinet, Buffer.MaplePacketRead slea)
        {
            //throw new NotImplementedException();
            string[] Test = new string[15];// = slea.ReadMapleAsciiString();

            //0 帐号 1 密码 2 姓名 3 日期 4 号码 5 问题1 6 答案1 7问题2 8答案2 9邮件地址 10身份证号码 11手机号码 

            /* 05 00 61 61 61 61 61 
             * 08 00 31 32 33 34 35 36 37 38 
             * 04 00 BA C3 C2 FD 
             * 0A 00 31 39 39 39 2F 30 39 2F 30 35 
             * 00 00 
             * 09 00 31 32 33 34 35 36 37 38 39 
             * 09 00 33 33 33 33 33 33 33 33 33 
             * 09 00 36 35 39 38 36 33 33 33 33 
             * 09 00 32 32 32 32 32 32 32 32 32 
             * 11 00 78 7A 6B 6D 78 64 40 76 69 70 2E 71 71 2E 63 6F 6D 0F 00 31 32 33 34 35 36 37 38 39 31 31 31 31 31 31 00 00 00 00 00 00 00 00*/


            /*
             * 08 00 61 61 61 61 61 61 73 73 
             * 06 00 31 32 33 34 35 36 
             * 06 00 D3 C3 BB A7 C3 FB 
             * 0A 00 31 39 39 32 2F 30 35 2F 30 35 
             * 00 00 
             * 09 00 31 32 33 34 35 36 37 38 39 
             * 09 00 31 32 33 34 35 38 37 34 34 
             * 09 00 39 38 37 36 35 34 33 32 31 
             * 09 00 31 32 35 34 37 38 35 35 35 
             * 11 00 78 7A 6B 6D 78 64 40 76 69 70 2E 71 71 2E 63 6F 6D 
             * 0F 00 31 32 33 34 35 36 37 38 39 31 32 33 33 31 31 
             * 00 00 
             * 01 00 
             * 00 00 
             * 00 00
             */

            for (int i = 0; i < 12; i++)
            {
                Test[i] = slea.ReadMapleAsciiString();
            }

            //性别
            short Sex = slea.ReadShort();

            slea.Skip(4);

            bool isUse = clinet.isRegisterAccount(Test[0], Test[1], Test[9], Sex);

            //注册成功提示
            clinet.Send(MapleLoginPacket.RegisterHint(isUse ? 0 : 1));

        }
    }


    /// <summary>
    /// 服务器状态
    /// </summary>
    public class MapleServerStateHandle : MaplePacketHandler
    {

        public void HandlePacket(MapleClient clinet, Buffer.MaplePacketRead slea)
        {
            //服务器ID
            int SreverID = slea.ReadShort();



        }
    }

}
